home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Netware Super Library
/
Netware Super Library.iso
/
mis_cnvt
/
par212
/
int.inf
< prev
next >
Wrap
Text File
|
1992-10-22
|
10KB
|
308 lines
███████████████████████████████████████████████████████████████████████████████
█░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░█
█░░░░░░░░░░░░░░░░░░░░░░░░░ PARSE-O-MATIC ░░░░░░░░░░░░░░░░░░░░░░░░░░░█
█░░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░░░░░░░█
███████████████████████████████████████████████████████████████████████████████
Copyright (C) 1992
by
Pinnacle Software
CP 386 Mount Royal
Mont Royal, Quebec
Canada H3P 3C6
(514) 345-9578
Created for Pinnacle Software
by
Timothy Campbell
1250 Laird #1A
Montreal, Quebec
Canada H3P 2T2
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
INTRODUCTION
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
WHY YOU NEED PARSE-O-MATIC
──────────────────────────
There are plenty of programs out there that have valuable data locked away
inside them. How do you get that data OUT of one program and into another one?
Some programs provide a feature which "exports" a file into some kind of
generic format. Perhaps the most popular of these formats is known as a
"comma-delimited file", which is a text file in which each data field is
separated by a comma. Literal strings -- which might contain commas! -- are
represented in double quotes. So a few lines from a comma-delimited file might
look something like this (an export from a hypothetical database of people who
owe your company money):
┌────────────────────────────────────────────────────────────────┐
│ "JONES","FRED","1234 GREEN AVENUE", "KANSAS CITY", "MO",293.64 │
│ "SMITH","JOHN","2343 OAK STREET","NEW YORK","NY",22.50 │
│ "WILLIAMS","JOSEPH","23 GARDEN CRESCENT","TORONTO","ON",16.99 │
└────────────────────────────────────────────────────────────────┘
Unfortunately, not all programs export data in this format, and not all
programs READ data in that format. What's most annoying of all is when one
program exports data in a format that is ALMOST what you need!
If that's the case, you might find that it's worth your while to spend a few
hours in a text editor, modifying the export file so that the other program
can understand it. Or you might write a program to do the editing for you.
Both solutions are time-consuming.
An even more challenging problem arises when a program which has no export
capability DOES have the ability to "print" reports to a file. You can write a
program to read these files and convert them to something you can use, but this
can be a LOT of work!
PARSE-O-MATIC TO THE RESCUE!
────────────────────────────
Parse-O-Matic is a utility that interprets text files and converts them to
other formats. It can help you "boil down" reports into their essential data.
You can also use it to convert NEARLY compatible file formats.
As a demonstration, I have provided you with an example parsing job which reads
a report from an inventory system and produces a comma-delimited file.
HOW IT WORKS
────────────
You need three things:
1) The Parse-O-Matic program
2) A Parse-O-Matic "POM" file (to tell Parse-O-Matic what to do)
3) The input file
The input file is usually a report from another program. The example I've
provided (POMSAMPL.TXT) comes from the AccPac accounting software. AccPac is a
great program, but its export capabilities leave something to be desired.
After writing dozens of custom programs for a friend, to parse his AccPac
reports, I decided to create Parse-O-Matic for him. Now you can use it.
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
HOW TO PROGRAM THE POM FILE
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
THE PARSE-O-MATIC COMMAND
─────────────────────────
The format of the Parse-O-Matic command line is:
POM pom-file input-file output-file
Here's an example, as you would type it at the DOS command line:
POM POMFILE.POM REPORT.TXT OUTPUT.TXT
For a more formal description of the command line, start up POM by typing this
command at the DOS prompt:
POM /?
THE POM FILE
────────────
The POM file is a text file with a .POM extension. The following conventions
are used:
■ Null lines and lines starting with a semi-colon are ignored.
■ A POM file may contain up to 500 lines of specifications.
Comment lines do not count in this total.
A POM file contains no "loops" (to use the programming term). Each line of the
input file interprets the entire POM file. If you'd like it expressed in terms
of programming languages, here's what POM does:
┌────────────────────────────────────────────────────────────────┐
│ START: If there's nothing left in the input file, go to QUIT. │
│ Read a line from the input file │
│ Do everything in the POM file │
│ Go to START │
│ QUIT: Tell the user you're finished! │
└────────────────────────────────────────────────────────────────┘
COMMAND WORDS
─────────────
This documentation assumes that you are an experienced computer user. If you
have trouble, you might ask a programmer to help you. If you're really stuck,
give me a call and I'll help you out.
MINLEN number
Specifies the minimum length a line must be to be considered for parsing.
(Note that null lines in the input file are always ignored)
IGNORE value1 value2
When value1 contains value2, the line is ignored and all further processing
on the line stops. The usual format of this command is something like:
IGNORE $FLINE[3 9] "Date"
This would skip any input line that contains the word "Date" between
columns 3 and 9 ($FLINE references the line just read).
IF value1 value2 var1 value3 [value4]
If value1 matches value2, var1 is set to value3. Otherwise, it is
set to value4. If value4 is missing, nothing is done (i.e. var1
is not changed).
OUT[END] value1 value2 |output-picture
This is two command words: OUT and OUTEND. OUT writes to the output
file without an end-of-line. OUTEND writes an end-of-line to the file.
When value1 matches value2, a line is output to the output file,
according to the output picture. Within the output picture, all
text is taken literally (i.e. " is taken to mean literally that --
a quotation mark character). The only exception to this is that
variable names are identified by the { and } characters. For
example, the line: OUTEND "X" "X" |{$FLUPC} would simply
output (in uppercase) every non-IGNOREd line in the input file.
NOTE: OUT does not actually write to the output file; it accumulates the
output. You must do an OUTEND to actually write the data. The maximum
line length allowed is 255 characters.
TRIM var1 spec1 character
Removes characters from var1. This is usually used to remove blanks.
spec1 can be: A=All B=Both ends L=Left side only R = Right side only
CHANGE var1 value1 value2
Replaces ALL occurances of value1 with value2
TRACE var1
Reports the value of var1 in the trace file (POM.TRC) if tracing has been
enabled (with the DOS command SET POM=T).
VALUES
──────
A value can be specified in the following ways:
"text" A literal text string
VARNAME The name of a variable
VARNAME[start end] A substring of a variable
VARNAME[start] A single character
VARNAME+ Increments variable (see explanation below)
Variable names can be up to 8 characters long. You can create up to 100
variables and literals (this number includes the predefined variables).
Parse-O-Matic predefines several variables. They are:
$FLINE = The line just read from the file
$FLUPC = The line just read from the file, in uppercase
$BRL = The { character (used in OUT)
$BRR = The } character (used in OUT)
IMPORTANT NOTE ABOUT DELIMITERS
───────────────────────────────
If you have to specify a quotation mark, use "". For example:
IGNORE "He said ""Hello"" to me."
This would ignore lines containing: He said "Hello" to me.
ILLEGAL CHARACTERS
──────────────────
No command can contain these ASCII characters:
■ $00 (Null)
■ $0A (LF)
■ $0D (CR)
Of course, LF and CR do appear at the very end of each line.
INCREMENTING
────────────
Only numeric incrementing is supported at this time. Attempting to increment
another type of variable will result in an error.
■ Incrementing "1" gives you "2"
■ Incrementing "9" gives you "10"
TRACING
───────
By setting the DOS variable POM to T, you can generate a trace file (POM.TRC).
This is helpful if you have trouble understanding why your file isn't being
parsed properly. But be sure to test it with a SMALL input file. The trace is
quite detailed, and it can easily generate a HUGE output file.
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
SPECIFICATIONS OF THE SAMPLE PARSING JOB
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
POM FILE: POMSAMPL.POM
INPUT FILE: POMSAMPL.TXT
OUTPUT FILE: TEST.TXT
COMMAND LINE: POM POMSAMPL.POM POMSAMPL.TXT TEST.TXT
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
CONCLUSION
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
Thanks for taking the time to check out Parse-O-Matic.
I hope it saves you time and money!